#ifndef SYSLOG_MANAGER_H
#define SYSLOG_MANAGER_H

#include <QObject>
#include <QString>
#include <QDateTime>
#include "system_logs.h"

class SysLogManager : public QObject
{
    Q_OBJECT

public:
    static SysLogManager* getInstance();

    // 记录日志的静态函数
    static void log(LogType logType, InfoType infoType, const QString& content);

    // 便捷函数
    static void logInfo(InfoType infoType, const QString& content);
    static void logSuccess(InfoType infoType, const QString& content);
    static void logError(InfoType infoType, const QString& content);
    static void logWarning(InfoType infoType, const QString& content);
    static void logDebug(InfoType infoType, const QString& content);

    // 具体业务场景的便捷函数
    static void logDeviceConnected(const QString& deviceInfo);
    static void logDeviceError(const QString& errorInfo);
    static void logPathPlanningComplete(int points, int commands);
    static void logCommandExecuted(const QString& command, bool isSuccess);
    static void logDatabaseConnected(const QString& dbInfo);
    static void logCameraError(const QString& errorInfo);
    static void logImageLoaded(const QString& imageInfo);
    static void logAutoExecutionProgress(int current, int total, const QString& step);
    // 数据库保存功能
    static void saveToDatabase(const QDateTime& time, LogType logType, InfoType infoType, const QString& content);

    // 类型转换辅助函数
    static QString logTypeToString(LogType type);
    static QString infoTypeToString(InfoType type);

signals:
    void logReceived(const QDateTime& time, int logType, int infoType, const QString& content);

private:
    explicit SysLogManager(QObject *parent = nullptr);


    // 禁止拷贝和赋值
    SysLogManager(const SysLogManager&) = delete;
    SysLogManager& operator=(const SysLogManager&) = delete;
};

#endif // SYSLOG_MANAGER_H
